﻿<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php $this->load->view('admin/header.html')?>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validateForm.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/ck.js"></script>
<script type="text/javascript">


    function addcolor() {
        layer.open({
            type: 2,
            title: '颜色添加',
            maxmin: true,
            shadeClose: false, //开启点击遮罩关闭层
            area: ['650px', '400px'],
            offset: ['100px', ''],
            content: '<?php echo site_url('admin/color/addcolor')?>'
        });
    }
    function editcolor(nid) {
        url = "<?php echo site_url('admin/color/editcolor/{nid}')?>";   
        url = url.replace('{nid}', nid) + "?returnurl=" + window.location.href;
        layer.open({
            type: 2,
            title: '颜色修改',
            maxmin: true,
            shadeClose: false, //开启点击遮罩关闭层
            area: ['650px', '400px'],
            offset: ['100px', ''],
            content: url
        });
    }
    function Success(data) {
        $.Success(data);
    }

     function Del(did)
    {
        var url = "/admin/color/del_color/" + did + "?returnurl=<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>";
        layer.confirm("删除此颜色，同时也会删除与此颜色关联的所有数据，确定删除?", function () {
            $.post(url, null, function (data) {
                var jsonData = $.parseJSON(data);
                if (jsonData.Statu == 'ok') {
                    Success(jsonData)
                }
                else {
                    Success(jsonData)
                }
            })
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }
    function BatchDel() {
        layer.confirm("确定要删除？", function (index) {
            if ($("#checkboxVal").val().length <= 0) {
                layer.msg('未选择删除项，删除取消', { icon: 0 });
                return false;
            }
            var url = "/admin/color/batchdel_color?returnurl=<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>";
            $.post(url, { "items": $("#checkboxVal").val() }, function (data) {
                if (data.Statu == "ok") {
                    Success(data)
                    $("#allcheck").attr("checked", false)
                } else {
                    Success(data)
                }
            }, "json")
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }


</script>

<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">
        DouPHP 管理中心
        <b>></b>
        <strong>颜色管理</strong>
    </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <h3>
            <a href="javascript:addcolor()" class="actionBtn">添加颜色</a>颜色管理
        </h3>
        <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
            <tr>
                <th width="50" align="center"><label for="allcheck">选择</label> <input type="checkbox" id="allcheck" name="allcheck" class="allcheck" /></th>
                <th width="30" align="center">编号</th>
                <th align="left">颜色描述</th>
                <th align="left">样式</th>
                <th align="center">操作</th>
            </tr>
            <?php foreach($colorList as $colorItem):?>
            <tr>
                <td align="center"><input type="checkbox" name="cklist" value="<?php echo $colorItem->color_id;?>" /></td>
                <td align="center"><?php echo $colorItem->color_id;?></td>               
                <td><?php echo $colorItem->title;?></td>
                <td><span style="float:left;display:block;height:40px;width:40px;"><img style="width:30px;vertical-align:middle;" src="<?php echo $colorItem->colorkey?>" /></span></td>
                <td align="center">
                    <a href="javascript:editcolor(<?php echo $colorItem->color_id?>)">编辑</a>|
                    <a href="javascript:Del(<?php echo $colorItem->color_id?>)">删除</a>
                </td>
            </tr>
            <?php endforeach; ?>
            <tr>
                <td colspan="10"><a href="javascript:BatchDel(14)">全部删除</a></td>
            </tr>
        </table>
        <input type="hidden" value="" id="checkboxVal" />
        <div class='page'>
            <?php echo $links?>
        </div>
    </div>
</div>